package com.karaoke.android.data.domain;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.Date;

import io.realm.RealmObject;
import io.realm.annotations.PrimaryKey;

public class DataDictionary extends RealmObject implements Parcelable {
    @PrimaryKey
    private Integer id;

    private String name;

    private Integer key;

    private Integer parentId;

    private Integer sortNo;

    private String image;

    private Date updateDate;

    private String remark;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name == null ? null : name.trim();
    }

    public Integer getKey() {
        return key;
    }

    public void setKey(Integer key) {
        this.key = key;
    }

    public Integer getParentId() {
        return parentId;
    }

    public void setParentId(Integer parentId) {
        this.parentId = parentId;
    }

    public Integer getSortNo() {
        return sortNo;
    }

    public void setSortNo(Integer sortNo) {
        this.sortNo = sortNo;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image == null ? null : image.trim();
    }

    public Date getUpdateDate() {
        return updateDate;
    }

    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark == null ? null : remark.trim();
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeValue(this.id);
        dest.writeString(this.name);
        dest.writeValue(this.key);
        dest.writeValue(this.parentId);
        dest.writeValue(this.sortNo);
        dest.writeString(this.image);
        dest.writeLong(this.updateDate != null ? this.updateDate.getTime() : -1);
        dest.writeString(this.remark);
    }

    public DataDictionary() {
    }

    protected DataDictionary(Parcel in) {
        this.id = (Integer) in.readValue(Integer.class.getClassLoader());
        this.name = in.readString();
        this.key = (Integer) in.readValue(Integer.class.getClassLoader());
        this.parentId = (Integer) in.readValue(Integer.class.getClassLoader());
        this.sortNo = (Integer) in.readValue(Integer.class.getClassLoader());
        this.image = in.readString();
        long tmpUpdateDate = in.readLong();
        this.updateDate = tmpUpdateDate == -1 ? null : new Date(tmpUpdateDate);
        this.remark = in.readString();
    }

    public static final Parcelable.Creator<DataDictionary> CREATOR = new Parcelable.Creator<DataDictionary>() {
        @Override
        public DataDictionary createFromParcel(Parcel source) {
            return new DataDictionary(source);
        }

        @Override
        public DataDictionary[] newArray(int size) {
            return new DataDictionary[size];
        }
    };
}